package day07;

public class String03 {
    public static void main(String[] args) {                //字符串不断旋转并比较
        String A="abcde",B="bcdea";
        System.out.println(Replace(A,B));
    }

    public static boolean Replace(String str1,String str2) {
        if(str1.length()!=str2.length()){return false;}
        StringBuilder sb1=new StringBuilder(str1);
        for(int i=0;i<sb1.length();i++) {
            if(compare(sb1,str2)) return true;
            StringBuilder temp=new StringBuilder();
            for(int j=0;j<sb1.length()-1;j++) {
                temp.append(sb1.charAt(j+1));
            }
            sb1=temp.append(sb1.charAt(0));
        }
        return false;
    }

    public static boolean compare(StringBuilder sb1,String str2) {
        if(sb1.toString().equals(str2)){return true;}
        else {return false;}
    }
}
